home *** CD-ROM | disk | FTP | other *** search
- //=============================================================================
- //
- // Fx-bwipe.c - Transition effect plug-in (Band Wipe).
- //
- // Part of the Adobe Premiere 4.2 Plug-in Developer's Toolkit.
- //
- // Copyright 1993-96, Adobe Systems Incorporated, all rights reserved worldwide.
- //
- // Written by Nick Schlott.
- //
- // 1.00 1/25/94 njs
- // 1.02 1/10/96 ba Updated for Premiere 4.2 and MSVC++ 2.2 & 4.0.
- //
- //-----------------------------------------------------------------------------
-
- #include <windows.h>
-
- #include "Compat.h"
- #include "Premiere.h"
-
-
- #define kDefBands 7
-
- HINSTANCE resInst; // reference to our DLL resources
- EffectHandle myData=NULL;
-
-
- BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
- {
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- resInst = hDLL;
- break;
-
- case DLL_THREAD_ATTACH:
- break;
-
- case DLL_THREAD_DETACH:
- break;
-
- case DLL_PROCESS_DETACH:
- break;
- }
- return(TRUE);
- }
-
-
- /*----------------------------------------------
- Center a window relative to the screen
- Useful for centering dialogs
- -----------------------------------------------*/
-
- VOID FAR center_wnd_higher (HWND hwnd)
- {
- RECT crct, box;
- int phgt, pwid;
- HWND parent;
-
- if ((parent = GetParent(hwnd)))
- {
- GetClientRect(parent, &box);
- pwid = box.right-box.left;
- phgt = box.bottom-box.top;
- }
- else
- {
- pwid = GetSystemMetrics(SM_CXSCREEN);
- phgt = GetSystemMetrics(SM_CYSCREEN);
- }
-
- GetWindowRect(hwnd, &crct);
- pwid = (pwid - (crct.right-crct.left)) / 2;
- phgt = ((phgt - (crct.bottom-crct.top))*2)/6;
- SetWindowPos(hwnd, NULL, pwid, phgt, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
- }
-
-
- //--------------------------------------------------------------------------
- // Proc for the filter param dialog
-
- BOOL CALLBACK AskDlogProc (HWND wnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- int cmdid;
- short HMAX;
- BOOL trans;
-
- switch(message)
- {
- case WM_INITDIALOG:
- myData = (EffectHandle)lParam;
- if ((*myData)->specsHandle)
- {
- HMAX = (*((short**)(*myData)->specsHandle))[0];
- }
- else
- {
- HMAX = kDefBands;
- }
- SetDlgItemInt(wnd, 10, HMAX, 0);
- SendDlgItemMessage(wnd, 10, EM_SETSEL, 0, MAKELONG(0,32767));
- SendDlgItemMessage(wnd, 10, EM_LIMITTEXT, 2, 0);
- SetFocus(GetDlgItem(wnd, 10));
- center_wnd_higher(wnd);
- return TRUE;
-
- case WM_CLOSE:
- EndDialog(wnd, (short)lParam);
- break;
-
- case WM_COMMAND:
- cmdid = LOWORD(wParam);
- switch (cmdid)
- {
- case IDOK:
- HMAX = GetDlgItemInt(wnd, 10, &trans, 0);
- if(HMAX <=2 || HMAX > 32)
- {
- MessageBeep(0);
- if(HMAX <=2)
- SetDlgItemInt(wnd, 10, 3, 0);
- else
- SetDlgItemInt(wnd, 10, 32, 0);
- SetFocus(GetDlgItem(wnd, 10));
- }
- else
- {
- if (!(*myData)->specsHandle)
- (*myData)->specsHandle = NewHandle(sizeof(short));
- if ((*myData)->specsHandle)
- {
- (*((short**)(*myData)->specsHandle))[0] = HMAX;
- }
- SendMessage(wnd, WM_CLOSE, cmdid, 0);
- }
- return TRUE;
-
- case IDCANCEL:
- SendMessage(wnd, WM_CLOSE, cmdid, 1);
- return TRUE;
- }
- break;
- }
- return FALSE;
- }
-
-
-
- //--------------------------------------------------------------------------
- void AddPolyPt (LPPOINT pts, short *cnt, int h, int v)
- {
- pts[*cnt].x = h;
- pts[*cnt].y = v;
- *cnt = (*cnt) + 1;
- }
-
-
- //--------------------------------------------------------------------------
- int PRMEXPORT xEffect (short selector, EffectHandle theData)
- {
- short hpart, vpart, width, height, i;
- short hdiv, vdiv, dist, offset, thisoffset, off1, off2;
- HRGN rgn1, rgn2;
- RECT fullbox, partbox;
- PPixHand srcpix1, srcpix2, dstpix;
- short numbands;
- POINT pt1, pt2;
- LPPOINT pts;
- short numpts;
- short result = 0;
-
- switch(selector)
- {
- case esSetup:
- myData = NULL;
- result = DialogBoxParam(resInst, MAKEINTRESOURCE(1000),
- GetLastActivePopup(GetMainWnd()),
- (DLGPROC)AskDlogProc, (LPARAM)theData);
- break;
- case esExecute:
- if ((*theData)->specsHandle) {
- numbands = **((short**)(*theData)->specsHandle);
- }
- else numbands = kDefBands;
-
- srcpix1 = ((*theData)->source1);
- srcpix2 = ((*theData)->source2);
- dstpix = ((*theData)->destination);
-
- hdiv = vdiv = 1;
- if ((*theData)->sizeFlags & gvHalfH) vdiv = 2;
- if ((*theData)->sizeFlags & (gvHalfV+gvFieldsEven+gvFieldsOdd)) hdiv = 2;
- if ((hdiv == 2) && (vdiv == 2)) hdiv = vdiv = 1;
-
- fullbox = partbox = (*dstpix)->bounds;
- width = (short)(fullbox.right-fullbox.left);
- height = (short)(fullbox.bottom-fullbox.top);
- hpart = (short)((long)(*theData)->part * width / (*theData)->total);
- vpart = (short)((long)(*theData)->part * height / (*theData)->total);
- dist = height/vdiv/2 + width/hdiv/2;
- offset = (short)((*theData)->part * (long)dist / (*theData)->total);
-
- ((*theData)->bottleNecks->StretchBits)(*srcpix2, *dstpix, &fullbox, &fullbox, 0, NULL);
-
- pts = (LPPOINT)NewPtr(100);
-
- rgn1 = CreateRectRgnIndirect(&fullbox);
- for (i=0; i<numbands; i++)
- {
- partbox = fullbox;
- numpts=0;
- switch ((*theData)->arrowFlags)
- {
- case bitUpperLeft+bitLowerRight:
- pt1.x = fullbox.left + width/2;
- pt1.y = fullbox.top - (short)(width*(long)vdiv/hdiv/2);
- pt2.x = fullbox.right + (short)(height*(long)hdiv/vdiv/2);
- pt2.y = fullbox.top + height/2;
- off1 = (short)(i * (long)dist / numbands);
- off2 = (short)((i+1) * (long)dist / numbands);
- thisoffset = (i&1) ? (dist-offset):-(dist-offset);
- AddPolyPt(pts, &numpts,pt1.x+(thisoffset-off1)*hdiv,pt1.y+(thisoffset+off1)*vdiv);
- AddPolyPt(pts, &numpts,pt1.x+(thisoffset-off2)*hdiv,pt1.y+(thisoffset+off2)*vdiv);
- AddPolyPt(pts, &numpts,pt2.x+(thisoffset-off2)*hdiv,pt2.y+(thisoffset+off2)*vdiv);
- AddPolyPt(pts, &numpts,pt2.x+(thisoffset-off1)*hdiv,pt2.y+(thisoffset+off1)*vdiv);
- AddPolyPt(pts, &numpts,pt1.x+(thisoffset-off1)*hdiv,pt1.y+(thisoffset+off1)*vdiv);
- rgn2 = CreatePolygonRgn(pts, numpts, ALTERNATE);
- CombineRgn(rgn1,rgn1,rgn2,RGN_DIFF);
- DeleteObject(rgn2);
- break;
- case bitLowerLeft+bitUpperRight:
- pt1.x = fullbox.left - (short)(height*(long)hdiv/vdiv/2);
- pt1.y = fullbox.top + height/2;
- pt2.x = fullbox.left + width/2;
- pt2.y = fullbox.top - (short)(width*(long)vdiv/hdiv/2);
- off1 = (short)(i * (long)dist / numbands);
- off2 = (short)((i+1) * (long)dist / numbands);
- thisoffset = (i&1) ? (dist-offset):-(dist-offset);
- AddPolyPt(pts,&numpts,pt1.x+(off1-thisoffset)*hdiv,pt1.y+(off1+thisoffset)*vdiv);
- AddPolyPt(pts,&numpts,pt1.x+(off2-thisoffset)*hdiv,pt1.y+(off2+thisoffset)*vdiv);
- AddPolyPt(pts,&numpts,pt2.x+(off2-thisoffset)*hdiv,pt2.y+(off2+thisoffset)*vdiv);
- AddPolyPt(pts,&numpts,pt2.x+(off1-thisoffset)*hdiv,pt2.y+(off1+thisoffset)*vdiv);
- AddPolyPt(pts,&numpts,pt1.x+(off1-thisoffset)*hdiv,pt1.y+(off1+thisoffset)*vdiv);
- rgn2 = CreatePolygonRgn(pts, numpts, ALTERNATE);
- CombineRgn(rgn1,rgn1,rgn2,RGN_DIFF);
- DeleteObject(rgn2);
- break;
- case bitTop+bitBottom:
- partbox.left = (short)((long)width * i / numbands);
- partbox.right = (short)((long)width * (i+1) / numbands);
- if (i&1) partbox.bottom = partbox.top + vpart;
- else partbox.top = partbox.bottom - vpart;
- rgn2 = CreateRectRgnIndirect(&partbox);
- CombineRgn(rgn1,rgn1,rgn2,RGN_DIFF);
- DeleteObject(rgn2);
- break;
- default:
- partbox.top = (short)((long)height * i / numbands);
- partbox.bottom = (short)((long)height * (i+1) / numbands);
- if (i&1) partbox.right = partbox.left + hpart;
- else partbox.left = partbox.right - hpart;
- rgn2 = CreateRectRgnIndirect(&partbox);
- CombineRgn(rgn1,rgn1,rgn2,RGN_DIFF);
- DeleteObject(rgn2);
- break;
- }
- }
- ((*theData)->bottleNecks->StretchBits)(*srcpix1, *dstpix, &fullbox, &fullbox, 0, rgn1);
- DeleteObject(rgn1);
- DisposPtr((Ptr)pts);
- break;
- }
- return result;
- }
-